package day04;

import java.util.Scanner;

public class test07 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入起始值：");
        int min = sc.nextInt();
        System.out.println("请输入最大值：");
        int max = sc.nextInt();
        System.out.println("请输入猜的值：");
        int n = sc.nextInt();
        int r = (int) (Math.random() * (max - min) + min);

        if (min < max) {
            while (n != r) {
                if (n > r) {
                    max = n;
                    System.out.println("猜大了，" + min + "~" + max);
                } else {
                    min = n;
                    System.out.println("猜小了，" + min + "~" + max);
                }
                n = sc.nextInt();
            }
            System.out.println("猜对了");
        } else {
            System.out.println("猜错了");
        }
    }
}
